package com.frogs.ucenter.v1.request;

import javax.servlet.http.HttpServletRequest;

import com.frogs.framework.util.StringUtil;
import com.frogs.framework.web.HttpRequestInfo;
import com.frogs.system.util.ApiUrlParamEnum;
import com.frogs.system.web.api.request.Request;
import com.frogs.system.web.exception.RequestIllegalException;

/**
 * 开发平台发送激活邮件请求参数类
 *
 * @author lijian
 * @version 2014年7月10日 - 上午9:36:14
 */
public class OpenPlatformSendActivateEmailRequest extends Request {
	
	private String openId;
	
	private Integer openPlatformId;
	
	private String email;
	
	@Override
	public void parse(HttpServletRequest request) {
		HttpRequestInfo requestInfo = new HttpRequestInfo(request);
		
		this.openId = requestInfo.getParameter(ApiUrlParamEnum.openId.getParamName(), "");
		this.openPlatformId = requestInfo.getIntParameter(ApiUrlParamEnum.openPlatformId.getParamName(), 0);
		this.email = requestInfo.getParameter(ApiUrlParamEnum.email.getParamName(), "");
		if (StringUtil.isEmpty(openId)) {
			throw new RequestIllegalException("openId不能为空");
		}
		if (openPlatformId == 0) {
			throw new RequestIllegalException("error openPlatformId " + openPlatformId);
		}
		if (!StringUtil.isEmail(email)) {
			throw new RequestIllegalException("请输入正确的邮箱地址");
		}
		
	}

	public String getOpenId() {
		return openId;
	}

	public void setOpenId(String openId) {
		this.openId = openId;
	}

	public Integer getOpenPlatformId() {
		return openPlatformId;
	}

	public void setOpenPlatformId(Integer openPlatformId) {
		this.openPlatformId = openPlatformId;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

}
